﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MGI/Map24MGI.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


//definition of the imgKey
$imgKey = "123456";


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];


// definition of the request body
$request = new GetBufferedBitmapImageRequest();
$request->ImageKey = $imgKey;

// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mgi = new Map24MGI($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mgi->getBufferedBitmapImage($header,$request);


// ------------------------------------------------------------------
// SAVE IMG DATA IN THE SESSION
// ------------------------------------------------------------------


// Save the BitmapData in the Session, to show it in another file
$_SESSION['IMG']=base64_encode($response->BitmapData);


// ------------------------------------------------------------------
// OUTPUT THE RESULT AS IMAGE
// ------------------------------------------------------------------

if(isset($response->BitmapData) )
{
	$resultString = "<img src='./img.php?".SID."' border='0'>";
}
else
{
	$resultString = "Nothing found for ImageKey: $imgKey";
}
?>